<?php
/*
$JA#COPYRIGHT$
*/
// no direct access
defined('_JEXEC') or die('Restricted access');

class modJAListEmployersHelper{
	function get_list_profiles( $model, $mode, $employer_list, $is_hiring=1, $limit ){
		global $jbconfig, $mainframe;				
		
		$limitstart = 0;
		
		$where_more = ' and a.approved=1 ';
		$where_more .= " and rs.block=0";
        $join = '';
		if( $mode=='featured' && $employer_list ){
			if(is_array($employer_list)) $employer_list = implode(',', $employer_list);
            $where_more .= " and a.id in ($employer_list)";
            if($is_hiring) $where_more .= ' and emplo.hiring='. (int)$is_hiring;
            
            $join = ' INNER JOIN #__ja_employers as e ON emplo.user_id=a.user_id';
		}
		$order = "";
		if($mode != 'featured')
			$order = "a.id desc";
		$all_items = $model->getItems($where_more, $limit, $limitstart, $order, $join);			
		return $all_items;
	}
	
	function getFile($name, $modPath, $tmplPath) {
		if (file_exists(JPATH_SITE.DS.$tmplPath.$name)) {
			return $tmplPath.$name;
		}
		return $modPath.$name;
	}
	
	function _findItem()
	{
		$needles = array(
			'view' => 'jajobs',
			'layout'  => 'jalist'
		);
		$component =& JComponentHelper::getComponent('com_jajobboard');

		$menus	= &JApplication::getMenu('site', array());
		$items	= $menus->getItems('componentid', $component->id);

		$match = null;
		
		if (is_array($items))
		foreach($items as $item)
		{
			if ((@$item->query['view'] == 'jajobs') && (@$item->query['layout'] == 'jalist')) {
				$match = $item;
				break;
			}
		}
		
		if($match)	return $match->id;
		return null;
	}
}